import QtQuick 1.0
import com.nokia.symbian 1.0

//main application window
ApplicationWindow {
    id: window

    function setStateIfFound(target, name) {
        for (var i = 0; i < target.states.length; i++) {
            var curState = target.states[i];
            if(curState.name == name) {
                target.state = name
                break
            }
        }
    }


    ToolBarLayout {
        id: commonTools

        ToolButton {
            flat: true
            iconSource: "qrc:/toolbar_back.svg"
            onClicked: pageStack.depth <= 1 ? Qt.quit() : pageStack.pop()
        }




            ToolButton {
                flat: true
                iconSource: "qrc:/toolbar_play.svg"
                onClicked:
                {
                    systemModel.play()
                    displayStatus.text = systemModel.returnMessage()
                }
        }

            ToolButton {
                flat: true
                iconSource: "qrc:/toolbar_pause.svg"
                onClicked:
                {
                    systemModel.pause()
                    displayStatus.text = systemModel.returnMessage()
                }
        }
            ToolButton {
                flat: true
                iconSource: "qrc:/toolbar_stop.svg"
                onClicked:
                {
                    systemModel.stop()
                    displayStatus.text = systemModel.returnMessage()
                }
            }

    }

    Page {
        id: page
        anchors.fill: parent
        tools: commonTools
        Component.onCompleted: {
            if(screen.currentOrientation == Screen.Portrait) {
                setStateIfFound(page, "PortraitState")
            } else if(screen.currentOrientation == Screen.Landscape) {
                setStateIfFound(page, "LandscapeState")
            }
        }

        // Image displayed on the application window
        Image {
            id: imagePoster
            y:window.TopLeft
            x:window.TopLeft
            height: window.height
            width:  window.width
            source: "qrc:/music.bmp"
            }

        // Text to display the application name.
        PageHeading{
            id: heading
            anchors.top: parent.top
            width: parent.width
            text: "Audio Player"
            fontItalic: true
        }
        //Text to display the status of the Audio player.
        Text {
                id:displayStatus
                text: "New Stories Stopped"
                font.family: "Helvetica"
                font.pointSize: 10
                color: "grey"
                font.italic :true
                width: 100
                height: 40
                y:(window.height/2- 100)
                anchors.rightMargin: parent.right
               }


    }

    Component.onCompleted: pageStack.push(page)
}

